home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / xmen.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  17KB  |  485 lines

  1. /***************************************************************************
  2.  
  3. X-Men
  4.  
  5. driver by Nicola Salmoria
  6.  
  7. ***************************************************************************/
  8. #include "driver.h"
  9. #include "vidhrdw/konamiic.h"
  10. #include "machine/eeprom.h"
  11.  
  12.  
  13.  
  14. int xmen_vh_start(void);
  15. void xmen_vh_stop(void);
  16. void xmen_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  17.  
  18.  
  19. static READ_HANDLER( K052109_halfword_r )
  20. {
  21.     return K052109_r(offset >> 1);
  22. }
  23.  
  24. static WRITE_HANDLER( K052109_halfword_w )
  25. {
  26.     if ((data & 0x00ff0000) == 0)
  27.         K052109_w(offset >> 1,data & 0xff);
  28. }
  29.  
  30. static WRITE_HANDLER( K053251_halfword_w )
  31. {
  32.     if ((data & 0x00ff0000) == 0)
  33.         K053251_w(offset >> 1,data & 0xff);
  34. }
  35.  
  36.  
  37.  
  38. /***************************************************************************
  39.  
  40.   EEPROM
  41.  
  42. ***************************************************************************/
  43.  
  44. static int init_eeprom_count;
  45.  
  46.  
  47. static struct EEPROM_interface eeprom_interface =
  48. {
  49.     7,                /* address bits */
  50.     8,                /* data bits */
  51.     "011000",        /*  read command */
  52.     "011100",        /* write command */
  53.     0,                /* erase command */
  54.     "0100000000000",/* lock command */
  55.     "0100110000000" /* unlock command */
  56. };
  57.  
  58. static void nvram_handler(void *file,int read_or_write)
  59. {
  60.     if (read_or_write)
  61.         EEPROM_save(file);
  62.     else
  63.     {
  64.         EEPROM_init(&eeprom_interface);
  65.  
  66.         if (file)
  67.         {
  68.             init_eeprom_count = 0;
  69.             EEPROM_load(file);
  70.         }
  71.         else
  72.             init_eeprom_count = 10;
  73.     }
  74. }
  75.  
  76. static READ_HANDLER( eeprom_r )
  77. {
  78.     int res;
  79.  
  80. logerror("%06x eeprom_r\n",cpu_get_pc());
  81.     /* bit 6 is EEPROM data */
  82.     /* bit 7 is EEPROM ready */
  83.     /* bit 14 is service button */
  84.     res = (EEPROM_read_bit() << 6) | input_port_2_r(0);
  85.     if (init_eeprom_count)
  86.     {
  87.         init_eeprom_count--;
  88.         res &= 0xbfff;
  89.     }
  90.     return res;
  91. }
  92.  
  93. static WRITE_HANDLER( eeprom_w )
  94. {
  95. logerror("%06x: write %04x to 108000\n",cpu_get_pc(),data);
  96.     if ((data & 0x00ff0000) == 0)
  97.     {
  98.         /* bit 0 = coin counter */
  99.         coin_counter_w(0,data & 0x01);
  100.  
  101.         /* bit 2 is data */
  102.         /* bit 3 is clock (active high) */
  103.         /* bit 4 is cs (active low) */
  104.         EEPROM_write_bit(data & 0x04);
  105.         EEPROM_set_cs_line((data & 0x10) ? CLEAR_LINE : ASSERT_LINE);
  106.         EEPROM_set_clock_line((data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
  107.     }
  108.     else
  109.     {
  110.         /* bit 8 = enable sprite ROM reading */
  111.         K053246_set_OBJCHA_line((data & 0x0100) ? ASSERT_LINE : CLEAR_LINE);
  112.         /* bit 9 = enable char ROM reading through the video RAM */
  113.         K052109_set_RMRD_line((data & 0x0200) ? ASSERT_LINE : CLEAR_LINE);
  114.     }
  115. }
  116.  
  117. static READ_HANDLER( xmen_sound_r )
  118. {
  119.     /* fake self test pass until we emulate the sound chip */
  120.     return 0x000f;
  121. }
  122.  
  123. static WRITE_HANDLER( xmen_sound_w )
  124. {
  125.     if (offset == 0)
  126.     {
  127.         if ((data & 0x00ff0000) == 0)
  128.             soundlatch_w(0,data & 0xff);
  129.     }
  130.     if (offset == 2) cpu_cause_interrupt(1,0xff);
  131. }
  132.  
  133. static WRITE_HANDLER( xmen_18fa00_w )
  134. {
  135.     /* bit 2 is interrupt enable */
  136.     interrupt_enable_w(0,data & 0x04);
  137. }
  138.  
  139. static WRITE_HANDLER( sound_bankswitch_w )
  140. {
  141.     int bankaddress;
  142.     unsigned char *RAM = memory_region(REGION_CPU2);
  143.  
  144.  
  145.     bankaddress = 0x10000 + (data & 0x07) * 0x4000;
  146.     cpu_setbank(4,&RAM[bankaddress]);
  147. }
  148.  
  149.  
  150.  
  151. static struct MemoryReadAddress readmem[] =
  152. {
  153.     { 0x000000, 0x03ffff, MRA_ROM },
  154.     { 0x080000, 0x0fffff, MRA_ROM },
  155.     { 0x100000, 0x100fff, K053247_word_r },
  156.     { 0x101000, 0x101fff, MRA_BANK2 },
  157.     { 0x104000, 0x104fff, paletteram_word_r },
  158.     { 0x108054, 0x108055, xmen_sound_r },
  159.     { 0x10a000, 0x10a001, input_port_0_r },
  160.     { 0x10a002, 0x10a003, input_port_1_r },
  161.     { 0x10a004, 0x10a005, eeprom_r },
  162.     { 0x10a00c, 0x10a00d, K053246_word_r },
  163.     { 0x110000, 0x113fff, MRA_BANK1 },    /* main RAM */
  164.     { 0x18c000, 0x197fff, K052109_halfword_r },
  165.     { -1 }    /* end of table */
  166. };
  167.  
  168. static struct MemoryWriteAddress writemem[] =
  169. {
  170.     { 0x000000, 0x03ffff, MWA_ROM },
  171.     { 0x080000, 0x0fffff, MWA_ROM },
  172.     { 0x100000, 0x100fff, K053247_word_w },
  173.     { 0x101000, 0x101fff, MWA_BANK2 },
  174.     { 0x104000, 0x104fff, paletteram_xBBBBBGGGGGRRRRR_word_w, &paletteram },
  175.     { 0x108000, 0x108001, eeprom_w },
  176.     { 0x108020, 0x108027, K053246_word_w },
  177.     { 0x10804c, 0x10804f, xmen_sound_w },
  178.     { 0x108060, 0x10807f, K053251_halfword_w },
  179.     { 0x10a000, 0x10a001, watchdog_reset_w },
  180.     { 0x110000, 0x113fff, MWA_BANK1 },    /* main RAM */
  181.     { 0x18fa00, 0x18fa01, xmen_18fa00_w },
  182.     { 0x18c000, 0x197fff, K052109_halfword_w },
  183.     { -1 }    /* end of table */
  184. };
  185.  
  186. static struct MemoryReadAddress sound_readmem[] =
  187. {
  188.     { 0x0000, 0x7fff, MRA_ROM },
  189.     { 0x8000, 0xbfff, MRA_BANK4 },
  190.     { 0xc000, 0xdfff, MRA_RAM },
  191.     { 0xec01, 0xec01, YM2151_status_port_0_r },
  192.     { 0xf002, 0xf002, soundlatch_r },
  193.     { -1 }    /* end of table */
  194. };
  195.  
  196. static struct MemoryWriteAddress sound_writemem[] =
  197. {
  198.     { 0x0000, 0xbfff, MWA_ROM },
  199.     { 0xc000, 0xdfff, MWA_RAM },
  200.     { 0xe800, 0xe800, YM2151_register_port_0_w },
  201.     { 0xec01, 0xec01, YM2151_data_port_0_w },
  202. //    { 0xf000, 0xf000, soundlatch2_w },    /* to main cpu */
  203.     { 0xf800, 0xf800, sound_bankswitch_w },
  204.     { -1 }    /* end of table */
  205. };
  206.  
  207.  
  208.  
  209. INPUT_PORTS_START( xmen )
  210.     PORT_START    /* IN1 */
  211.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  212.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  213.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  214.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  215.     PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  216.     PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  217.     PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  218.     PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_COIN2 )
  219.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER4 )
  220.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER4 )
  221.     PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER4 )
  222.     PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER4 )
  223.     PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER4 )
  224.     PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER4 )
  225.     PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER4 )
  226.     PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_COIN4 )
  227.  
  228.     PORT_START    /* IN0 */
  229.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
  230.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
  231.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
  232.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
  233.     PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  234.     PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  235.     PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
  236.     PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_COIN1 )
  237.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER3 )
  238.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER3 )
  239.     PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER3 )
  240.     PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER3 )
  241.     PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER3 )
  242.     PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER3 )
  243.     PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER3 )
  244.     PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_COIN3 )
  245.  
  246.     PORT_START    /* COIN  EEPROM and service */
  247.     PORT_BIT( 0x003f, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* unused? */
  248.     PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_UNKNOWN )    /* EEPROM data */
  249.     PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* EEPROM status - always 1 */
  250.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_START1 )
  251.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_START2 )
  252.     PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_START3 )
  253.     PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_START4 )
  254.     PORT_BIT( 0x3000, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* unused? */
  255.     PORT_BITX(0x4000, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
  256.     PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* unused? */
  257. INPUT_PORTS_END
  258.  
  259. INPUT_PORTS_START( xmen2p )
  260.     PORT_START    /* IN1 */
  261.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  262.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  263.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  264.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  265.     PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  266.     PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  267.     PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  268.     PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_COIN2 )
  269. /*
  270.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER4 )
  271.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER4 )
  272.     PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER4 )
  273.     PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER4 )
  274.     PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER4 )
  275.     PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER4 )
  276.     PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER4 )
  277.     PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_COIN4 )
  278. */
  279.  
  280.     PORT_START    /* IN0 */
  281.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
  282.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
  283.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
  284.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
  285.     PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  286.     PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  287.     PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
  288.     PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_COIN1 )
  289. /*
  290.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER3 )
  291.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER3 )
  292.     PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER3 )
  293.     PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER3 )
  294.     PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER3 )
  295.     PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER3 )
  296.     PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER3 )
  297.     PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_COIN3 )
  298. */
  299.  
  300.     PORT_START    /* COIN  EEPROM and service */
  301.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN3 )
  302.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN4 )
  303.     PORT_BIT( 0x003c, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* unused? */
  304.     PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_UNKNOWN )    /* EEPROM data */
  305.     PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* EEPROM status - always 1 */
  306.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_START1 )
  307.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_START2 )
  308.     PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
  309.     PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
  310.     PORT_BIT( 0x3000, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* unused? */
  311.     PORT_BITX(0x4000, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
  312.     PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* unused? */
  313. INPUT_PORTS_END
  314.  
  315.  
  316.  
  317. static struct YM2151interface ym2151_interface =
  318. {
  319.     1,            /* 1 chip */
  320.     3579545,    /* 3.579545 MHz */
  321.     { YM3012_VOL(100,MIXER_PAN_LEFT,100,MIXER_PAN_RIGHT) },
  322.     { 0 }
  323. };
  324.  
  325.  
  326.  
  327. static int xmen_interrupt(void)
  328. {
  329.     if (cpu_getiloops() == 0) return m68_level5_irq();
  330.     else return m68_level3_irq();
  331. }
  332.  
  333. static struct MachineDriver machine_driver_xmen =
  334. {
  335.     /* basic machine hardware */
  336.     {
  337.         {
  338.             CPU_M68000,
  339.             16000000,    /* ? */
  340.             readmem,writemem,0,0,
  341.             xmen_interrupt,2
  342.         },
  343.         {
  344.             CPU_Z80 | CPU_AUDIO_CPU,
  345.             2*3579545,    /* ????? */
  346.             sound_readmem,sound_writemem,0,0,
  347.             ignore_interrupt,0    /* IRQs are triggered by the main CPU */
  348.         }
  349.     },
  350.     60, DEFAULT_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  351.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  352.     0,
  353.  
  354.     /* video hardware */
  355.     64*8, 32*8, { 14*8, (64-14)*8-1, 2*8, 30*8-1 },
  356.     0,    /* gfx decoded by konamiic.c */
  357.     2048, 2048,
  358.     0,
  359.  
  360.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  361.     0,
  362.     xmen_vh_start,
  363.     xmen_vh_stop,
  364.     xmen_vh_screenrefresh,
  365.  
  366.     /* sound hardware */
  367.     SOUND_SUPPORTS_STEREO,0,0,0,
  368.     {
  369.         {
  370.             SOUND_YM2151,
  371.             &ym2151_interface
  372.         }
  373.     },
  374.  
  375.     nvram_handler
  376. };
  377.  
  378.  
  379.  
  380. /***************************************************************************
  381.  
  382.   Game driver(s)
  383.  
  384. ***************************************************************************/
  385.  
  386. ROM_START( xmen )
  387.     ROM_REGION( 0x100000, REGION_CPU1 )
  388.     ROM_LOAD_EVEN( "065ubb04.10d",  0x00000, 0x20000, 0xf896c93b )
  389.     ROM_LOAD_ODD ( "065ubb05.10f",  0x00000, 0x20000, 0xe02e5d64 )
  390.     ROM_LOAD_EVEN( "xmen17g.bin",   0x80000, 0x40000, 0xb31dc44c )
  391.     ROM_LOAD_ODD ( "xmen17j.bin",   0x80000, 0x40000, 0x13842fe6 )
  392.  
  393.     ROM_REGION( 0x30000, REGION_CPU2 )        /* 64k+128k fpr sound cpu */
  394.     ROM_LOAD( "065-a01.6f",   0x00000, 0x20000, 0x147d3a4d )
  395.     ROM_RELOAD(               0x10000, 0x20000 )
  396.  
  397.     ROM_REGION( 0x200000, REGION_GFX1 )    /* graphics (addressable by the main CPU) */
  398.     ROM_LOAD( "xmen1l.bin",   0x000000, 0x100000, 0x6b649aca )    /* tiles */
  399.     ROM_LOAD( "xmen1h.bin",   0x100000, 0x100000, 0xc5dc8fc4 )
  400.  
  401.     ROM_REGION( 0x400000, REGION_GFX2 )    /* graphics (addressable by the main CPU) */
  402.     ROM_LOAD( "xmen12l.bin",  0x000000, 0x100000, 0xea05d52f )    /* sprites */
  403.     ROM_LOAD( "xmen17l.bin",  0x100000, 0x100000, 0x96b91802 )
  404.     ROM_LOAD( "xmen22h.bin",  0x200000, 0x100000, 0x321ed07a )
  405.     ROM_LOAD( "xmen22l.bin",  0x300000, 0x100000, 0x46da948e )
  406.  
  407.     ROM_REGION( 0x200000, REGION_SOUND1 )    /* samples for the 054544 */
  408.     ROM_LOAD( "xmenc25.bin",  0x000000, 0x200000, 0x5adbcee0 )
  409. ROM_END
  410.  
  411. ROM_START( xmen6p )
  412.     ROM_REGION( 0x100000, REGION_CPU1 )
  413.     ROM_LOAD_EVEN( "xmenb04.bin",   0x00000, 0x20000, 0x0f09b8e0 )
  414.     ROM_LOAD_ODD ( "xmenb05.bin",   0x00000, 0x20000, 0x867becbf )
  415.     ROM_LOAD_EVEN( "xmen17g.bin",   0x80000, 0x40000, 0xb31dc44c )
  416.     ROM_LOAD_ODD ( "xmen17j.bin",   0x80000, 0x40000, 0x13842fe6 )
  417.  
  418.     ROM_REGION( 0x30000, REGION_CPU2 )        /* 64k+128k fpr sound cpu */
  419.     ROM_LOAD( "065-a01.6f",   0x00000, 0x20000, 0x147d3a4d )
  420.     ROM_RELOAD(               0x10000, 0x20000 )
  421.  
  422.     ROM_REGION( 0x200000, REGION_GFX1 )    /* graphics (addressable by the main CPU) */
  423.     ROM_LOAD( "xmen1l.bin",   0x000000, 0x100000, 0x6b649aca )    /* tiles */
  424.     ROM_LOAD( "xmen1h.bin",   0x100000, 0x100000, 0xc5dc8fc4 )
  425.  
  426.     ROM_REGION( 0x400000, REGION_GFX2 )    /* graphics (addressable by the main CPU) */
  427.     ROM_LOAD( "xmen12l.bin",  0x000000, 0x100000, 0xea05d52f )    /* sprites */
  428.     ROM_LOAD( "xmen17l.bin",  0x100000, 0x100000, 0x96b91802 )
  429.     ROM_LOAD( "xmen22h.bin",  0x200000, 0x100000, 0x321ed07a )
  430.     ROM_LOAD( "xmen22l.bin",  0x300000, 0x100000, 0x46da948e )
  431.  
  432.     ROM_REGION( 0x200000, REGION_SOUND1 )    /* samples for the 054544 */
  433.     ROM_LOAD( "xmenc25.bin",  0x000000, 0x200000, 0x5adbcee0 )
  434. ROM_END
  435.  
  436. ROM_START( xmen2pj )
  437.     ROM_REGION( 0x100000, REGION_CPU1 )
  438.     ROM_LOAD_EVEN( "065jaa04.10d",  0x00000, 0x20000, 0x66746339 )
  439.     ROM_LOAD_ODD ( "065jaa05.10f",  0x00000, 0x20000, 0x1215b706 )
  440.     ROM_LOAD_EVEN( "xmen17g.bin",   0x80000, 0x40000, 0xb31dc44c )
  441.     ROM_LOAD_ODD ( "xmen17j.bin",   0x80000, 0x40000, 0x13842fe6 )
  442.  
  443.     ROM_REGION( 0x30000, REGION_CPU2 )        /* 64k+128k fpr sound cpu */
  444.     ROM_LOAD( "065-a01.6f",   0x00000, 0x20000, 0x147d3a4d )
  445.     ROM_RELOAD(               0x10000, 0x20000 )
  446.  
  447.     ROM_REGION( 0x200000, REGION_GFX1 )    /* graphics (addressable by the main CPU) */
  448.     ROM_LOAD( "xmen1l.bin",   0x000000, 0x100000, 0x6b649aca )    /* tiles */
  449.     ROM_LOAD( "xmen1h.bin",   0x100000, 0x100000, 0xc5dc8fc4 )
  450.  
  451.     ROM_REGION( 0x400000, REGION_GFX2 )    /* graphics (addressable by the main CPU) */
  452.     ROM_LOAD( "xmen12l.bin",  0x000000, 0x100000, 0xea05d52f )    /* sprites */
  453.     ROM_LOAD( "xmen17l.bin",  0x100000, 0x100000, 0x96b91802 )
  454.     ROM_LOAD( "xmen22h.bin",  0x200000, 0x100000, 0x321ed07a )
  455.     ROM_LOAD( "xmen22l.bin",  0x300000, 0x100000, 0x46da948e )
  456.  
  457.     ROM_REGION( 0x200000, REGION_SOUND1 )    /* samples for the 054544 */
  458.     ROM_LOAD( "xmenc25.bin",  0x000000, 0x200000, 0x5adbcee0 )
  459. ROM_END
  460.  
  461.  
  462.  
  463. static void init_xmen(void)
  464. {
  465.     konami_rom_deinterleave_2(REGION_GFX1);
  466.     konami_rom_deinterleave_4(REGION_GFX2);
  467. }
  468.  
  469. static void init_xmen6p(void)
  470. {
  471.     unsigned char *RAM = memory_region(REGION_CPU1);
  472.  
  473.     WRITE_WORD(&RAM[0x21a6],0x4e71);
  474.     WRITE_WORD(&RAM[0x21a8],0x4e71);
  475.     WRITE_WORD(&RAM[0x21aa],0x4e71);
  476.  
  477.     init_xmen();
  478. }
  479.  
  480.  
  481.  
  482. GAMEX( 1992, xmen,    0,    xmen, xmen,   xmen,   ROT0, "Konami", "X-Men (4 Players)", GAME_IMPERFECT_SOUND )
  483. GAMEX( 1992, xmen6p,  xmen, xmen, xmen,   xmen6p, ROT0, "Konami", "X-Men (6 Players)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
  484. GAMEX( 1992, xmen2pj, xmen, xmen, xmen2p, xmen,   ROT0, "Konami", "X-Men (2 Players Japan)", GAME_IMPERFECT_SOUND )
  485.